Grokking Scalable Systems for Interviews
Rate this course
Ask Author
Contribute
Back to course home

4% completed

Vote For New Content
Introduction
Course Overview
Who This Course Is for
Caching
What Is Negative Caching and When Should You Cache 404 or Empty Results?
What Is the Difference Between Soft TTL and Hard TTL, and Why Does It Matter?
How Can a Bloom Filter Reduce Cache or Database Load?
What Is Distributed Locking for Cache Rebuilds, and How Does It Prevent Cache Stampedes?
Load Balancing
What Are Sticky Sessions (Session Affinity) and When Should I Avoid Them?
What Is the Difference between Liveness Checks and Readiness Checks in Load Balancers?
What is Global Server Load Balancing (GSLB) and How GeoDNS and Anycast Work?
API Basics
What are the Main API Pagination Strategies (offset, cursor, keyset), and When Should I Use Each?
What are HTTP Conditional Requests (ETag, If‑None‑Match, Last‑Modified) and How They Reduce Load?
What Is the Difference between Rate Limiting and Throttling and Quotas?
What Are Idempotency Keys and How to Implement Them Safely for Payments
What are SQL Isolation Levels (Read Committed, Repeatable Read, Serializable), and What Anomalies Do They Prevent?
What Is a Write‑Ahead Log (WAL), and How Does It Ensure Durability?
What Is the Difference Between Synchronous and Asynchronous Replication, and When Should I Use Read Replicas?
What Is MVCC (Multi‑Version Concurrency Control), and How Does It Enable Concurrent Reads and Writes?
What Are Safe Patterns for Online Schema Changes vs. Offline Migrations?
What is Little’s Law and How to Use It for Quick Capacity Estimates in System Design
How Can I do Back-of-the-Envelope Sizing for QPS, Bandwidth, Storage, and Peak vs. Average Load?
What are Cold Starts and Warm Starts, and Why Do They Matter for Performance?
How Do I Choose a Good Shard Key and Avoid Hotspots (Bucketing and Key Randomization)?
What Are Range Sharding, Directory‑Based Sharding, and Geo‑Sharding, and What Are the Common Use Cases?
What Is the Difference Between Rendezvous Hashing and Consistent Hashing, and When Should I Use Each?
What Do At‑most‑once, At‑least‑once, And Exactly‑once Delivery Semantics Mean?
What Are Idempotent Producers And Consumers, And How Do De‑duplication Keys Work?
What Is Message Ordering, How Do Partition Keys Affect It, And When Can Ordering Break?
What Are Windowing And Watermarking In Streaming Systems, In Simple Terms?
What Is Quorum (N, R, W), And Why Does R + W > N Give Strongly Consistent Reads?
What Are Common Conflict Resolution Strategies (Last‑write‑wins, Vector Clocks, Logical Clocks)?
What Are Read Repair, Hinted Handoff, And Anti‑entropy (Merkle Trees) In Eventually Consistent Systems?
What Is The Difference Between SLI, SLO, And SLA, And Can You Give Simple Examples?
What Is Opentelemetry, And How Do Traces, Spans, Metrics, And Logs Fit Together?
What Is An Error Budget, And How Should It Guide Release Decisions?
What Are The Trade‑offs Between Server‑stored Sessions And JWTs for Authentication?
What Is The Difference Between TLS And MTLS, And When Is MTLS Appropriate For Service‑to‑service Auth?
What Is Secrets Management, And How Do Environment Variables, KMS, And Vault Compare?
What Is A Replay Attack, And How Is It Different from Idempotency Issues?
What Are The Differences Between TCP, UDP, And QUIC, And When Should I Use Each?
What Is The Difference Between A Forward Proxy, A Reverse Proxy, And NAT?
What Changed From HTTP/1.1 To HTTP/2 To HTTP/3, And What Are Head‑of‑line Blocking And Multiplexing?
What Is the Difference Between Content‑Addressable Storage and Location‑Based Addressing?
What Are Checksums and Etags, and How Do MD5/SHA Compare to CRC for Integrity?
What Are Hot, Warm, Cold, and Archive Storage Tiers, and When Should I Use Each?
What Is the Outbox Pattern, and How Does Change Data Capture (CDC) Work at a High Level?
What Is CQRS (Command Query Responsibility Segregation), and When Should I Consider It?
What Are the Differences Between a Circuit Breaker, Retry With Backoff, and Rate Limiting?
What Are RPO and RTO, and How Do They Differ in Disaster Recovery Planning?
What Is the Difference Between Active‑Active and Active‑Passive Architectures?
What Is Graceful Degradation, and How Do Feature Flags Help Availability?
What Are the Differences Between UUID, ULID, KSUID, and Snowflake IDs, and How Do I Choose?
How Do Snowflake‑Style IDs Work (Timestamp, Worker, Sequence), and What Problems Do They Solve?
What Is the Difference Between Wall‑Clock Time and Monotonic Time, and Why Is Clock Skew Hard?
Final Words
Key Takeaways
What To Learn Next
What are HTTP Conditional Requests (ETag, If‑None‑Match, Last‑Modified) and How They Reduce Load?

HTTP conditional requests are special HTTP requests that use headers (like ETag or Last-Modified) to check if a cached resource has changed, so unchanged content isn’t re-downloaded, reducing server load and saving bandwidth.

What Are HTTP Conditional Requests?

In web caching, a conditional request means the client (e.g. your browser) asks the server only to send a resource if certain conditions are met, typically, if the content has changed since the last time it was seen.

The client includes validator headers (such as an ETag or a date) with its request.

The server then compares these validators to the current version of the resource.

If nothing has changed, the server replies with a short “Not Modified” (HTTP 304) status and no response body, meaning the client can safely use its cached copy.

If the resource has changed, the server will send the full content (HTTP 200 OK) as usual, along with updated validators for next time.

This mechanism is built into HTTP and is key to efficient web performance.

ETag and Last-Modified are the two most common validators used in conditional requests:

  • ETag is a unique identifier (token) for a specific version of a resource. The server generates an ETag (often a hash or fingerprint of the content) for each version of a resource.

  • Last-Modified is a timestamp of when the resource was last changed on the server.

When a client caches a resource, it will store these validators.

Later, the client can make a conditional GET request with headers like If-None-Match (using the ETag value) or If-Modified-Since (using the last modified date).

These headers essentially mean “give me the resource only if it doesn’t match what I already have”.

Here are key differences between ETag and Last-Modified:

FeatureETagLast-Modified
DefinitionA unique identifier (string or hash) assigned by the server to represent a specific version of a resource.A timestamp indicating when the resource was last changed on the server.
Header Used For ValidationIf-None-Match (for GET) and If-Match (for PUT/DELETE).If-Modified-Since (for GET) and If-Unmodified-Since (for PUT/DELETE).
Type of ComparisonExact match of the identifier (strong or weak validation).Date/time comparison.
PrecisionVery precise — can detect even small or fast changes that happen multiple times per second.Limited precision (usually 1 second) — may miss rapid updates.
Server ControlFully controlled by the server; can be based on hash, checksum, version number, etc.Based on system clock — depends on file timestamp or last modification time.
Best ForDynamic content where changes aren’t always time-based or predictable.Static content like images or files where modification time is enough.
Cache ValidationPreferred for fine-grained cache validation (especially with CDNs or APIs).Simpler validation for basic HTTP caching.
OverheadSlightly higher (server must generate and manage ETags).Low (timestamp comes from filesystem).
Common HeadersETag, If-None-Match, If-Match.Last-Modified, If-Modified-Since, If-Unmodified-Since.

How Do ETag and If-None-Match Work?

ETag: A Resource’s Fingerprint

An ETag (or entity tag) is an identifier that the server attaches to a resource to represent its current state or version. It could be a hash of the file contents or a revision number.

Every time the resource changes, a new ETag is generated by the server.

For example, an image or JSON response might come with a header ETag: "abc123", which is a unique code for that version of the content.

If-None-Match: Validating by ETag

If-None-Match is the request header the client uses to make the GET request conditional based on an ETag.

The client sends If-None-Match: "abc123" (using the ETag it saved).

This header tells the server: “Send me the resource only if its current ETag does not match abc123”. In other words, “I have version abc123; give me a new copy only if there’s a different version.”

On the server side, the logic is: compare the client’s ETag with the latest ETag of the resource.

If they are the same, it means the resource has not changed, so the server responds with 304 Not Modified and no message body.

The server does not resend the content data, saving bandwidth.

If the ETag is different (meaning the resource has changed), the server will send the full resource with a normal 200 OK response and include the new ETag in the headers.

Why ETag?

ETags are very precise validators (they can detect even minor changes in content) and are ideal for cache validation.

By using ETag/If-None-Match, web servers avoid resending full responses if the content hasn’t changed, making caching more efficient and saving significant bandwidth.

ETags also have uses in preventing simultaneous update conflicts, but their primary use in this context is cache validation.

How Do Last-Modified and If-Modified-Since Work?

Last-Modified: A Resource’s Timestamp

Last-Modified is a timestamp indicating when the server believes the resource was last changed.

For example, a response might include Last-Modified: Tue, 15 Sep 2025 11:00:00 GMT. This date serves as a record of the resource’s update time.

If-Modified-Since: Validating by Date

If-Modified-Since is the request header where the client sends the last known modification date (from its cache).

For instance, If-Modified-Since: Tue, 15 Sep 2025 11:00:00 GMT tells the server: “Only send me the resource if it has been modified after September 15, 2025, 11:00:00 GMT.” The server will compare this date to the resource’s current last modified date.

If no changes have occurred after that time, the server replies with 304 Not Modified (meaning the cached copy is still good).

If there were changes after that date, the server responds with a fresh 200 OK and the updated content (plus a new Last-Modified date and possibly a new ETag).

Comparing ETag vs Last-Modified: Both serve the same general purpose of validation, but ETag is typically more accurate.

Last-Modified is a “weak validator” in the sense that it only has one-second precision and might not change if a file is modified multiple times within a second or if a server’s clock is off.

It also can’t detect changes if the file content remains the same but is rewritten. ETag, being content-based, can detect changes more reliably (byte-for-byte if a strong ETag).

However, not all servers or resources generate ETags, so Last-Modified is a good fallback mechanism and is widely used.

In practice, browsers often send both If-None-Match and If-Modified-Since together, and the server will use one or both validators to decide the response.

Check out HTTP/2 vs HTTP/1.1.

How Conditional Requests Reduce Load

HTTP conditional requests play a huge role in reducing load on networks and servers.

By avoiding sending data that the client already has, they make web communication much more efficient.

Here are the key ways conditional requests help:

  • Save Bandwidth: If a resource hasn’t changed, the server doesn’t send the entire file again. The response without a body (304 Not Modified) is very small (just headers), which reduces unnecessary data transfer. This is especially important for users on slow or metered connections and for bandwidth-constrained servers.

  • Decrease Server Load: The server does not have to re-generate or read the full resource from disk/database for every request if it’s unchanged. Serving a 304 is lighter work than serving a full 200 OK with a large payload. This means lower CPU, memory, and I/O usage on the server, allowing it to handle more users.

  • Lower Latency & Faster Load Times: Because there’s much less data to send, the response arrives faster. Pages can load quicker since the browser can instantly use cached files after a quick 304 check, instead of waiting to download everything again. This leads to a better user experience with snappier page navigation.

  • Improve Scalability: Efficient caching via conditional requests means each client only downloads updates, not the same data repeatedly. A website can serve more visitors with the same infrastructure because repeat requests don’t all translate into heavy data transfers. (Many content delivery networks and high-traffic sites rely on these mechanisms to offload work from origin servers.)

  • SEO and Crawling Benefits: Search engines use conditional requests when crawling websites. If your pages haven’t changed, a search engine crawler will get a 304 Not Modified and skip re-downloading the content. This conserves the site’s bandwidth and allows the crawler to use its time (crawl budget) more efficiently on new or updated content. In short, conditional requests help search engines crawl your site faster and more efficiently, which can indirectly benefit SEO.

It’s often said in web performance circles that “the fastest request is one that never has to be made, and the second fastest is one with no response body.”

In practice, conditional requests achieve the latter. The server’s 304 response contains no body, so the client just uses its local cache.

This makes the web application feel faster and lightens the load on servers.

Example Scenario: Conditional Request in Action

Let’s walk through a typical sequence using both ETag and Last-Modified validators:

  1. Initial Request: The browser requests a resource (for example, GET /styles.css) for the first time. The server responds with a 200 OK and the full content of the resource. Along with the content, the server sends validation headers, e.g. ETag: "abc123" and Last-Modified: Tue, 15 Sep 2025 11:00:00 GMT. The browser caches the resource as well as these header values.

  2. Subsequent Request: Now the user visits another page or reloads, and the browser needs /styles.css again. This time, instead of just sending an unconditional GET, the browser issues a conditional GET: it includes the previously stored validators in the request. For example, it sends:

    GET /styles.css HTTP/1.1
    Host: example.com
    If-None-Match: "abc123"
    If-Modified-Since: Tue, 15 Sep 2025 11:00:00 GMT

  3. These headers effectively say, “Give me /styles.css only if it’s different from what I have (ETag abc123) or if it’s been modified since 11:00 GMT Sept 15, 2025.”

  4. Server Check: The server receives this request and checks the current version of /styles.css. It compares the current ETag and last modified date of the file to the values provided by the client:

    • If the resource is unchanged: The current ETag still matches "abc123" (and the last modified date hasn’t changed). This means the client’s copy is up-to-date. The server responds with HTTP 304 Not Modified, and does not send the file again. The response is very small (just headers) and tells the browser its cached copy is still valid. The browser then loads the CSS from its cache, avoiding any download delay.

    • If the resource has changed: Suppose the CSS was updated on the server (the ETag is now different, say "xyz789", or the Last-Modified is newer). In this case, the server responds with 200 OK and the new content of /styles.css in the body, plus new ETag: "xyz789" and Last-Modified headers. The browser receives the updated file and replaces its cache with this new version for future requests.

  5. Outcome: In the unchanged scenario, the conditional request spared both parties from transferring the entire CSS file again. The 304 Not Modified response is tiny (just a few bytes of headers) compared to the file, so it loads much faster and uses minimal bandwidth. The server also didn’t have to spend time sending the file. In the changed scenario, the client got the update it needed. Either way, the conditional request ensured that the file is downloaded only when necessary, keeping the load as low as possible.

This example demonstrates the elegance of HTTP conditional requests: the client and server perform a quick check (“Has it changed?”) instead of blindly re-fetching everything.

Over millions of requests, this greatly reduces redundant data transfer and processing.

In fact, without the 304/conditional request mechanism, web caching would be far less effective. Browsers would have to either use potentially stale files or re-download all resources on each visit, which would be slow and data-heavy.

Conclusion

HTTP conditional requests (using ETags and Last-Modified dates with the corresponding If-None-Match/If-Modified-Since headers) are a cornerstone of modern web optimization.

They ensure that clients download only what they need, when they need it, and no more.

By validating caches and leveraging the 304 Not Modified response, they dramatically reduce bandwidth usage, decrease server workload, and speed up web pages.

This system benefits everyone: users enjoy faster load times, servers handle traffic more easily, and even search engines can crawl sites more efficiently.

In summary, conditional requests are a simple yet powerful concept. They ask “has this changed?” and if not, the best answer is just: “Nothing new, use what you have.”

What are the Main API Pagination Strategies (offset, cursor, keyset), and When Should I Use Each?
What Is the Difference between Rate Limiting and Throttling and Quotas?
Mark as Completed

On this page

What Are HTTP Conditional Requests?

How Do ETag and If-None-Match Work?

ETag: A Resource’s Fingerprint

If-None-Match: Validating by ETag

Why ETag?

How Do Last-Modified and If-Modified-Since Work?

Last-Modified: A Resource’s Timestamp

If-Modified-Since: Validating by Date

How Conditional Requests Reduce Load

Example Scenario: Conditional Request in Action

Conclusion